
#include <torch/torch.h>
#include <iostream>
#include "rayutil.h"

using namespace std;
void main(char* args)
{
	float o1[3] = { 1.0072, 0.3476, 1.6524 };
	float o2[3] = { 1.0072, 0.3476, 1.6524 };

	float d1[3] = { -0.4126, 0.34147, -0.84449 };
	float d2[3] = { -0.14027, 0.31328, -0.93924 };
	float box[6] = { -2, -2, -2, 2, 2, 2 };

	at::Tensor rays_o = torch::empty({ 2, 3 }, torch::kFloat32);
	at::Tensor rays_d = torch::empty({ 2, 3 }, torch::kFloat32);
	at::Tensor xyzs = torch::empty({ 2, 3, 3 }, torch::kFloat32).cuda();
	at::Tensor aabb = torch::from_blob(box, 6, torch::kFloat32).cuda();
	at::Tensor near = torch::empty(2, torch::kFloat32).cuda();
	at::Tensor far = torch::empty(2, torch::kFloat32).cuda();
	at::Tensor z_vals = torch::empty({ 2, 3 }, torch::kFloat32).cuda();
	at::Tensor deltas = torch::empty({ 2, 3 }, torch::kFloat32).cuda();
	rays_o[0] = torch::from_blob(o1, 3, torch::kFloat32);
	rays_o[1] = torch::from_blob(o2, 3, torch::kFloat32);
	rays_d[0] = torch::from_blob(d1, 3, torch::kFloat32);
	rays_d[1] = torch::from_blob(d2, 3, torch::kFloat32);
	rays_o = rays_o.cuda(); rays_d = rays_d.cuda();
	cout << rays_o << "\r\n" << endl;
	cout << rays_d << "\r\n" << endl;

	rays_coords(&rays_o, &rays_d, &aabb, 3, 0.2, 2, true, &near, &far, &xyzs, &z_vals, &deltas);

	cout << near << "\r\n" << endl;
	cout << far << "\r\n" << endl;
	cout << xyzs << "\r\n" << endl;
	cout << z_vals << "\r\n" << endl;
	cout << deltas << "\r\n" << endl;
}